package inventory.master.view;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
import javax.swing.JLabel;

import model.CategoryMaster;

import utility.ViewUtilities;
import viewframework.UIFrameWork;


import java.awt.Font;
import java.awt.Dimension;
import java.awt.SystemColor;

public class MasterManagementMainView extends JPanel implements MouseListener 
{
	private JLabel lblCategoryManagement;
	private JLabel lblMaterialManagement;
	private JLabel[]leftMenu;
	private JToolBar toolBar;
	private SpringLayout sl;
	
	public MasterManagementMainView() 
	{
		sl = new SpringLayout();
		setLayout(sl);
		setSize(1050,550);
			
		toolBar = new JToolBar();
		toolBar.setBackground(SystemColor.inactiveCaption);
		toolBar.setBorder(null);
		toolBar.setOrientation(SwingConstants.VERTICAL);
		sl.putConstraint(sl.SOUTH, toolBar, 0, sl.SOUTH, this);
		sl.putConstraint(sl.NORTH, toolBar, 1, sl.NORTH, this);
		sl.putConstraint(sl.WEST, toolBar, 0, sl.WEST, this);
		sl.putConstraint(sl.EAST, toolBar, 180, sl.WEST, this);
		makeLeftMenu();
		addButtonsInToolBar();
		addButtonListener();
		add(toolBar);
	}
	
	
	
	private void makeLeftMenu()
	{
		leftMenu=new JLabel[2];
		
		lblCategoryManagement=new JLabel("Category Management",SwingConstants.CENTER);
		lblCategoryManagement.setPreferredSize(new Dimension(72, 40));
		lblCategoryManagement.setMinimumSize(new Dimension(180, 40));
		lblCategoryManagement.setMaximumSize(new Dimension(180, 40));
		lblCategoryManagement.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		leftMenu[0]=lblCategoryManagement;
		
		lblMaterialManagement=new JLabel("Material Management",SwingConstants.CENTER);
		lblMaterialManagement.setPreferredSize(new Dimension(72, 40));
		lblMaterialManagement.setMinimumSize(new Dimension(180, 40));
		lblMaterialManagement.setMaximumSize(new Dimension(180, 40));
		lblMaterialManagement.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		leftMenu[1]=lblMaterialManagement;
		
		for(int k=0;k<leftMenu.length;k++)
			leftMenu[k].setBorder(null);
	}
	
	
	private void addButtonsInToolBar()
	{
		toolBar.add(lblCategoryManagement);
		toolBar.addSeparator();
		toolBar.add(lblMaterialManagement);
		toolBar.addSeparator();
		
	}
	
	private void addButtonListener()
	{
		for(JLabel temp:this.leftMenu)
			 temp.addMouseListener(this);
	}
	
	@Override
	public void mouseClicked(MouseEvent arg0) 
	{
		if(arg0.getSource() instanceof JLabel)
		{
			JLabel label=(JLabel) arg0.getSource();
			
			if(label==lblCategoryManagement)
			{
				CategoryManagementView cmv=new CategoryManagementView();
				UIFrameWork.setFormComponent(sl,cmv,this,2);
			}
				
			
			if(label==lblMaterialManagement)
			{
				MaterialManagementView mmv=new MaterialManagementView();
				UIFrameWork.setFormComponent(sl, mmv, this,2);
			}
		}
	}


	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
}
